# pip install -U langchain-community faiss-cpu langchain-openai tiktoken
#pip install faiss-cpu
# 如果您需要使用没有 AVX2 优化的 FAISS 进行初始化，请取消下面一行的注释
# os.environ['FAISS_NO_AVX2'] = '1'

from langchain_community.document_loaders import TextLoader
from langchain_community.vectorstores import FAISS
from langchain_openai import OpenAIEmbeddings
from langchain_text_splitters import CharacterTextSplitter

from config.embedding_config import get_openai_embeddings_local

embeddings = get_openai_embeddings_local()

db = FAISS.load_local("faiss_index", embeddings,allow_dangerous_deserialization=True)
query = "Pixar公司是做什么的?"
retriever = db.as_retriever()
docs = retriever.invoke(query)
print(docs[0].page_content)